package com.example.demo.project; /**
 * 编辑人：刘凯
 */

import java.util.Scanner;

// 账户类
public class Account {
    private String accountNumber;
    private String ownerName;
    private double balance;
    private Deposit deposit;
    private Scanner input = new Scanner(System.in);

    public Account(String accountNumber, String ownerName) {
        this.accountNumber = accountNumber;
        this.ownerName = ownerName;
        this.balance = 0;
    }

    // 获取账户金额
    public void deposit(Deposit deposit) {
        this.deposit = deposit;
        balance += deposit.getAmount();
    }

    // 取款方法
    public void withdraw() {
        balance = deposit.getBalance();
        System.out.print("请输入取款金额：");
        double wb = input.nextDouble();
        if (balance >= wb) {
            balance -= wb;
            deposit.setAmount(balance - deposit.getInterest());
            deposit.withdraw();
        } else {
            System.out.println("余额不足，无法取款");
        }
    }

    // 展示信息
    public void displayAccountInfo() {
        deposit.displayInfo();
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public String getOwnerName() {
        return ownerName;
    }
}
